package edu.gmu.middleware;

/**
 * EndianFlag enums.
 *
 * @author  James H. Pope
 * @version $Revision:$ $Date:$
 */
public class EndianFlag
{   
    /**
     * BigEndian Flag to indicate that the following message is BigEndian.
     */
    public static final EndianFlag BIG_ENDIAN =
            new EndianFlag( 0xDEADBEEF, "BIG_ENDIAN" );

    /**
     * LittleEndian Flag to indicate that the following message is LittleEndian.
     */
    public static final EndianFlag LITTLE_ENDIAN =
            new EndianFlag( 0xEFBEADDE, "LITTLE_ENDIAN" );
    
    
    //------------------------------------------------------------------------//
    
    /**
     * id
     */
    private int id = 0;
    
    /**
     * name
     */
    private String name = null;
    
    
    
    /**
     * Creates a new EndianFlag with specified values.
     * @param id
     * @param name
     */
    public EndianFlag( int id , String name )
    {
        this.id     = id;
        this.name   = name;
    }
    
    /**
     * Gets id.
     * @return id
     */
    public int getId()
    {
        return this.id;
    }
    
    /**
     * Gets name.
     * @return name
     */
    public String getName()
    {
        return this.name;
    }
     
     /**
      * Gets enum from given id
      * @param id of enum to get
      * @return enum of given id or null if not found
      */
     public static EndianFlag get( int id )
     {
         EndianFlag enumeration = null;
         if( id == BIG_ENDIAN.id )
         {
             enumeration = BIG_ENDIAN;
         }
         else if( id == LITTLE_ENDIAN.id )
         {
             enumeration = LITTLE_ENDIAN;
         }
         return enumeration;
     }
     
     
     /**
      * Gets this String facsimile of this object.
      * @return name
      */
     public String toString( )
     {
         return this.name;
     }
}
